<?php

namespace App\Service;

use Illuminate\Http\Response;

class DataReturnService
{
	public static function returnOk( $data='ok', $msg='成功',$cookieToken='token')
	{
		$reData['code'] = 200;
		$reData['data'] = $data;
		$reData['msg'] = $msg;
		return response()->json($reData)->cookie('cookieToken', 'value', $cookieToken);
		die;
	}

	public static function returnErr( $data='err',$code='-1',$msg='失败',$cookieToken='token')
	{
		$reData['code'] = $code;
		$reData['data'] = $data;
		$type = gettype($msg);
		if($type=='object'){
			$msg = json_encode($msg);
		}
		if($type=='array'){
			$msg = implode(' ',$msg);
		}
		$reData['msg'] = $msg;
		return response()->json($reData)->cookie('cookieToken', 'value', $cookieToken);
		die;
	}

}